package com.lswms.modules.lswms.dao.base;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.lswms.common.dao.BaseDao;
import com.lswms.modules.lswms.entity.base.LocationEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 库位
 *
 * @author DX sunlightcs@gmail.com
 * @since 1.0.0 2021-06-04
 */
@Mapper
public interface LocationDao extends BaseDao<LocationEntity> {

    @Select("select loc_category from lswms_location where location=#{location}")
    String checkLoc_category(@Param("location")String location);

    
    @Select("select lswms_location.* ,lswms_zone.zonename,a.listname  loc_typestr,b.listname loc_categorystr,c.listname loc_statusstr,d.listname ismixedskustr,e.listname ismixedlot1str,\n"
    		+ "	f.listname ismixedlot2str,g.listname ismixedlot3str,h.listname ismixedlot4str, i.listname ismixedlot5str,j.listname ismixedlot6str,k.listname ismixedlot7str,\n"
    		+ "	l.listname ismixedlot8str,m.listname ismixedlot9str,n.listname ismixedlot10str, o.listname ismixedlot11str ,p.listname ismixedlot12str,q.listname ismixedlot13str,\n"
    		+ "	r.listname ismixedlot14str,s.listname ismixedlot15str, t.listname iscreatestr , u.listname ismixedtraystr \n"
    		+ " from  lswms_location left join lswms_zone  on lswms_location.zonecode = lswms_zone.zonecode\n"
    		+ "		left join lswms_codelist a on  lswms_location.loc_type  = a.list and a.code ='loc_type'\n"
    		+ "		left join lswms_codelist b on  lswms_location.loc_category  = b.list and b.code ='loc_category'\n"
    		+ "		left join lswms_codelist c on  lswms_location.loc_status  = c.list and c.code ='loc_status'\n"
    		+ "		left join lswms_codelist d on  lswms_location.ismixedsku  = d.list and d.code ='Ismixed'\n"
    		+ "		left join lswms_codelist e on  lswms_location.ismixedlot1  = e.list and e.code ='Ismixed'\n"
    		+ "		left join lswms_codelist f on  lswms_location.ismixedlot2  = f.list and f.code ='Ismixed'\n"
    		+ "		left join lswms_codelist g on  lswms_location.ismixedlot3  = g.list and g.code ='Ismixed'\n"
    		+ "		left join lswms_codelist h on  lswms_location.ismixedlot4  = h.list and h.code ='Ismixed'\n"
    		+ "		left join lswms_codelist i on  lswms_location.ismixedlot5  = i.list and i.code ='Ismixed'\n"
    		+ "		left join lswms_codelist j on  lswms_location.ismixedlot6  = j.list and j.code ='Ismixed'\n"
    		+ "		left join lswms_codelist k on  lswms_location.ismixedlot7  = k.list and k.code ='Ismixed'\n"
    		+ "		left join lswms_codelist l on  lswms_location.ismixedlot8  = l.list and l.code ='Ismixed'\n"
    		+ "		left join lswms_codelist m on  lswms_location.ismixedlot9  = m.list and m.code ='Ismixed'\n"
    		+ "		left join lswms_codelist n on  lswms_location.ismixedlot10  = n.list and n.code ='Ismixed'\n"
    		+ "		left join lswms_codelist o on  lswms_location.ismixedlot11  = o.list and o.code ='Ismixed'\n"
    		+ "		left join lswms_codelist p on  lswms_location.ismixedlot12  = p.list and p.code ='Ismixed'\n"
    		+ "		left join lswms_codelist q on  lswms_location.ismixedlot13  = q.list and q.code ='Ismixed'\n"
    		+ "		left join lswms_codelist r on  lswms_location.ismixedlot14  = r.list and r.code ='Ismixed'\n"
    		+ "		left join lswms_codelist s on  lswms_location.ismixedlot15  = s.list and s.code ='Ismixed'\n"
    		+ "		left join lswms_codelist u on  lswms_location.ismixedtray  = u.list and u.code ='Ismixed'\n"
    		+ "		left join lswms_codelist t on  lswms_location.iscreate  = t.list and t.code ='YESORNO' ${ew.customSqlSegment} ")
	IPage<LocationEntity> selectPageBySql(IPage<LocationEntity> page, @Param(Constants.WRAPPER)QueryWrapper<LocationEntity> wrapper);

}
